package thread;

class MyThread01 extends Thread{
    @Override
    public void run() {
            String name = Thread.currentThread().getName();
        while (true){
            System.out.println(name+"->MyThread01.run()");
        }
    }
}
class MyThread02 extends Thread{
    @Override
    public void run() {
        String name = Thread.currentThread().getName();
        while (true){
            System.out.println(name+"->MyThread02.run()");
        }
    }
}


/**
 * @Author Justin Parker
 * @Date 2024/7/19 0019 14:35
 * @Version 1.0
 */
public class ThreadDemoo01 {

    public static void main(String[] args) {
        //获取main方法运行在哪个线程，这个线程名字是什么？
        System.out.println(Thread.currentThread().getName());
        //创建两个新的线程对象
        Thread t1=new MyThread01();
        Thread t2=new MyThread02();
        //启动线程对象
        t1.start(); //线程启动后获取了CPU会执行自己的run方法
        t2.start();
    }
}
